Skip to content

fix(gateway): warn once on unknown message types#450

Merged
mfaferek93 merged 2 commits into
mainfrom
fix/446-unknown-type-warn-once
Jun 21, 2026
Merged

fix(gateway): warn once on unknown message types#450
mfaferek93 merged 2 commits into
mainfrom
fix/446-unknown-type-warn-once

Conversation

@mfaferek93

Copy link
Copy Markdown
Collaborator

When a topic uses a message type whose package is not installed, the data sampler caught TypeNotFoundError and logged a warning on every sample (ros2_topic_data_provider.cpp), flooding the gateway log on stacks with custom messages.

Now the first occurrence of an unknown type is warned once and the type is recorded; subsequent samples of that type short-circuit before the deserialize attempt instead of re-logging. Access is guarded by a mutex (the sampling path runs in parallel).

Verified: colcon build --packages-up-to ros2_medkit_gateway compiles; clang-format-18 clean.

Closes #446

Data sampling logged a warning per message when a topic's message type
package was not installed, flooding the log on stacks with custom
messages. Warn once per type, then skip resampling that type.

Closes #446
Copilot AI review requested due to automatic review settings June 20, 2026 17:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces gateway log flooding during topic sampling when encountering ROS message types that cannot be deserialized (e.g., packages/typesupport not available), by warning only on first occurrence and skipping subsequent deserialize attempts for the same type. This aligns with the gateway’s operational goal of remaining usable on stacks that include custom/optional message packages.

Changes:

  • Track message types that raise TypeNotFoundError and short-circuit sampling for those types on future samples.
  • Make the “warn once” behavior thread-safe via a mutex-protected set shared across parallel samplers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/ros2_medkit_gateway/src/data/ros2_topic_data_provider.cpp Adds skip-fast-path for previously seen unknown types and warns only on first sighting (mutex-guarded).
src/ros2_medkit_gateway/include/ros2_medkit_gateway/data/ros2_topic_data_provider.hpp Introduces unsupported_types_ tracking state (mutex + set) to support warn-once/skip behavior.

Comment thread src/ros2_medkit_gateway/src/data/ros2_topic_data_provider.cpp
Comment thread src/ros2_medkit_gateway/src/data/ros2_topic_data_provider.cpp
@mfaferek93 mfaferek93 self-assigned this Jun 20, 2026
bburda
bburda previously approved these changes Jun 20, 2026

@bburda bburda left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the warn-once logic. The pre-check and the catch-block insert are both under the mutex, so it warns about an unknown type once and short-circuits later samples without crashing. Class already deletes copy/move, so the new mutex member is fine. CI green.

@bburda bburda dismissed their stale review June 20, 2026 20:14

Dismissing to complete a deeper review before sign-off.

bburda
bburda previously approved these changes Jun 20, 2026

@bburda bburda left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, duplicate msg.

Address review: cap the warn-once cache at 4096 entries so a graph
advertising many distinct unknown types cannot grow it without limit, and
surface its size as unsupported_type_count in stats() / x_medkit_stats().
@mfaferek93 mfaferek93 merged commit 9ee1052 into main Jun 21, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data sampling logs one warning per message on unknown message types

3 participants